package org.budo.weixin.work.api.entity;

import java.io.Serializable;

import com.alibaba.fastjson.JSONObject;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * @author lmw
 */
@Getter
@Setter
@NoArgsConstructor
public class ApprovalDetailSpRecordDetail implements SpRecordDetail, Serializable {
    private static final long serialVersionUID = -6883671076956530722L;

    private Integer index;

    private JSONObject json; // {"approver":{"userid":"LiuHaiJian"},"speech":"","sptime":1620725135,"media_id":[],"sp_status":2}

    public ApprovalDetailSpRecordDetail(Integer index, JSONObject json) {
        this.index = index;
        this.json = json;
    }

    @Override
    public String getSpeech() {
        return this.getJson().getString("speech");
    }

    @Override
    public Integer getSpRecordIndex() {
        return this.index;
    }

    @Override
    public String getSpStatus() {
        return this.getJson().getString("sp_status");
    }

    @Override
    public String getApproverUserId() {
        JSONObject approver = this.getJson().getJSONObject("approver");
        return approver.getString("userid");
    }

    @Override
    public String toString() {
        return "#" + this.getIndex() + " " + this.getApproverUserId() + " " + this.getSpStatus();
    }
}